File:Comparison of spectral leakage of several window functions.svg
Page contents not supported in other languages.
Tools
Actions
General
In other projects
Appearance
Size of this PNG preview of this SVG file: 800 × 343 pixels. Other resolutions: 320 × 137 pixels | 640 × 274 pixels | 1,024 × 439 pixels | 1,280 × 549 pixels | 2,560 × 1,097 pixels | 1,750 × 750 pixels.
Original file (SVG file, nominally 1,750 × 750 pixels, file size: 3.79 MB)
This is a file from the Wikimedia Commons. Information from its description page there is shown below. Commons is a freely licensed media file repository. You can help. |
Summary
DescriptionComparison of spectral leakage of several window functions.svg |
English: The spectral leakage of several window functions are plotted on the same coordinate system for comparison. |
|||
Date | ||||
Source | Own work | |||
Author | Bob K | |||
Permission (Reusing this file) |
I, the copyright holder of this work, hereby publish it under the following license:
|
|||
SVG development InfoField | V This vector image was created with GNU Octave. |
|||
Gnu Octave source InfoField | click to expand
graphics_toolkit gnuplot
#{
The gnuplot graphics toolkit is not actively maintained and has a number
of limitations that are unlikely to be fixed. Communication with gnuplot
uses a one-directional pipe and limited information is passed back to the
Octave interpreter so most changes made interactively in the plot window
will not be reflected in the graphics properties managed by Octave. For
example, if the plot window is closed with a mouse click, Octave will not
be notified and will not update its internal list of open figure windows.
The qt toolkit is recommended instead.
#}
% Just a bunch of defaults copied from File:Window_function_and_frequency_response_-_Rectangular.svg
set(0, "DefaultAxesFontName", "Microsoft Sans Serif")
set(0, "DefaultTextFontName", "Microsoft Sans Serif")
set(0, "DefaultAxesTitleFontWeight", "bold")
set(0, "DefaultAxesFontWeight", "bold")
set(0, "DefaultAxesFontSize", 14)
set(0, "DefaultAxesLineWidth", 2)
set(0, "DefaultAxesBox", "on")
set(0, "DefaultAxesGridLineStyle", "-")
set(0, "DefaultAxesGridColor", [0 0 0]) % black
set(0, "DefaultAxesGridAlpha", 0.1) % opaqueness of grid
set(0, "DefaultAxesLayer", "bottom") % grid not visible where overlapped by graph
M = 2^12; % interpolation factor
% An unusually large number is needed to resolve the first null of the Tukey window
DFT_length = 2^10;
window_length = DFT_length + 1;
DTFT_length = M*DFT_length;
dr = 100; % dynamic range
% These are the indices of the DTFT array that will be plotted logarithmically
a = M/4 : DTFT_length/2;
% These are the bin numbers to be assigned to the indices
x = (a-1)/M;
n = 2*pi*(0:DFT_length-1)/DFT_length;
%============================================
% Rectangular window
window = ones(1,DFT_length);
window(1) = 2*window(1); % periodic summation
H = abs(fft(window, DTFT_length));
H = H(a);
H = H/max(H);
H = 20*log10(H);
H = max(-dr,H);
figure("position", [1 1 1400 600])
semilogx(x, H, "color","black", "linewidth",1)
xlim([.25 20]) % display only 20 bins
ylim([-dr 2])
set(gca,"XTick", [.5 1:10])
set(gca,"XTickLabel",[".5"; "1"; "2"; "3"; "4"; "5"; "6"; "7"; "8"; "9"; "10"])
set(gca, "ygrid", "on");
ylabel("dB", "FontSize",14, "FontWeight","bold")
xlabel("DFT bins", "FontSize",14, "FontWeight","bold")
title("Spectral leakage of several window functions", "FontSize",20)
hold on
%============================================
% Hann window
window = 0.5 - 0.5*cos(n);
window(1) = 2*window(1); % periodic summation
H = abs(fft(window, DTFT_length));
H = H(a);
H = H/max(H);
H = 20*log10(H);
H = max(-dr,H);
semilogx(x, H, "color","red", "linewidth",1)
%============================================
% Hamming window
window = 0.53836 - 0.46164*cos(n);
window(1) = 2*window(1); % periodic summation
H = abs(fft(window, DTFT_length));
H = H(a);
H = H/max(H);
H = 20*log10(H);
H = max(-dr,H);
semilogx(x, H, "color","blue", "linewidth",1)
%============================================
% Tukey window
alpha = 0.5;
b = alpha*DFT_length/2;
window = ones(1,window_length);
m = 0 : b;
if( max(m) == b )
m = m(1:end-1);
endif
M = length(m);
window(1:M) = 0.5*(1-cos(pi*m/b));
window(window_length:-1:window_length-M+1) = window(1:M);
window(1) = 2*window(1); % periodic summation
window = window(1:end-1);
H = abs(fft(window, DTFT_length));
H = H(a);
H = H/max(H);
H = 20*log10(H);
H = max(-dr,H);
dark_green = [0 128 0]/256;
semilogx(x, H, "color",dark_green, "linewidth",2)
%============================================
% Blackman window
window = 0.42 - 0.5*cos(n) + 0.08*cos(2*n);
window(1) = 2*window(1); % periodic summation
H = abs(fft(window, DTFT_length));
H = H(a);
H = H/max(H);
H = 20*log10(H);
H = max(-dr,H);
gold = [251 159 3]/256;
semilogx(x, H, "color",gold, "linewidth",2)
%============================================
% Flat top window
b = [0.21557895 0.41663158 0.277263158 0.083578947 0.006947368];
window = b(1) - b(2)*cos(n) + b(3)*cos(2*n) -b(4)*cos(3*n) +b(5)*cos(4*n);
window(1) = 2*window(1); % periodic summation
H = abs(fft(window, DTFT_length));
H = H(a);
H = H/max(H);
H = 20*log10(H);
H = max(-dr,H);
semilogx(x, H, "color","magenta", "linewidth",2)
h = legend(['rectangular'],...
['hann'],...
['hamming'],...
['tukey'],...
['blackman'],...
['flattop'],...
"location","west");
legend boxoff
set(h, "fontsize",16);
|
Items portrayed in this file
depicts
1 May 2022
image/svg+xml
1845502a673ee569f1a89c513b609ff3f658bf26
3,972,356 byte
750 pixel
1,750 pixel
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 11:47, 1 May 2022 | 1,750 × 750 (3.79 MB) | Bob K | enlarge legend and add a tick at x=.5 | |
04:45, 1 May 2022 | 1,750 × 750 (3.8 MB) | Bob K | Uploaded own work with UploadWizard |
File usage
The following page uses this file:
Metadata
This file contains additional information, probably added from the digital camera or scanner used to create or digitize it.
If the file has been modified from its original state, some details may not fully reflect the modified file.
Width | 1400pt |
---|---|
Height | 600pt |